<?php $__env->startSection('title','积分兑换'); ?>

<?php $__env->startSection('css'); ?>
    <style>
        /*#d79705;渐变色调浅色：#dec07a*/
        body{
            background-color: #ECECEC;
        }
        .body{
            font-size: 14px;
        }
        .weui-navbar {

            position: relative;
        }
        .weui-navbar__item:after {

            border-right: none;

        }
        .weui-navbar:after {

            border-bottom: none;

        }
        .weui-tab__panel{
            display: none;
        }
        .weui-tab__panel{

        }
        .weui-navbar__item.weui-bar__item_on {
            border-bottom:2px solid #D58B00;
            background-color: #fff;
        }
        .weui-navbar {
            box-sizing: border-box;
            background-color: #fff;
            padding: 0 15px;
            border-bottom: 1px solid #ddd;
        }
        .weui-navbar+.weui-tab__panel {
            padding-top: 10px;
            padding-bottom: 50px;
        }
        .item{
            padding: 10px 15px;
            box-sizing: border-box;
            background: #fff;
            margin-bottom: 5px;
        }
        .item img{
            margin-right: 15px;
        }
        .item p{
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        .item.right{
            margin-left: 1%;
        }
        .need_credits{
            color: #E5B23A;
            font-size: 16px;
        }
        .desc{
            font-size: 12px;
            color: #aaa;
        }

        .exchange{
            outline: none;
            background: #E5B23A;
            border: 1px solid #E5B23A;
            color: #fff;
            width: 76px;
            height: 22px;
            font-size: 10px;
            border-radius: 15px;
            line-height: 17px;
            float: right;
        }

        #recharge{
            padding: 10px 0px;
        }
        .rechange_top{
            background-color: #fff;
        }
        .recharge_title{
            text-align: left;
            padding: 15px 5%;
        }
        .input_div{
            width: 90%;
            margin: 0 auto;
        }
        .input_div>input{
            width: 100%;
            border: none;
            border-bottom: 1px solid #ddd;
        }
        .credit_to_money{
            padding: 15px;
        }
        .exchange_button{
            width: 85%;
            border: none;
            background-color: #d79705;
            color: #fff;
            padding: 8px;
            border-radius: 8px;
        }
        .recharge_desc{
            text-align: left;
            margin-top: 20px;
            padding: 10px 9%;
        }
        .weui-navbar__item {
            padding: 7px 0;
        }
        .nav_bar{
            background-color: #fff;
            /*box-shadow: 0px 2px 12px 1px #D0D0D0;*/
            padding: 10px 15px;
            text-align: center;
            border-bottom: 1px solid #D0D0D0;
        }
        .nav_bar>.nav_back {
            background: url(/images/version1/icon_bar_back.png) no-repeat;
            background-size: 20px 20px;
            display: inline-block;
            float: left;
            color:gold;
        }
        .page{
            margin-top: 1px;
        }
        .excharge_record{
            color: #d79705;
            font-size: 12px;
            float: right;
        }

        .item_right{
            display: inline-block;
        }

        .item_right{
            width: 70%;
        }
        .title{
            font-size: 16px;
            padding: 10px 0px;
        }
        .recharge_cash{
            text-align: center;
            margin-top: 20px;
        }
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('container'); ?>
    <div class="body">
        <div class="nav_bar">
            积分兑换<div class="nav_back"></div>

            <a class="excharge_record" href="<?php echo e(route('oExchangeRecode')); ?>">兑换记录</a>

        </div>
        <div class="page navbar js_show">
            <div class="page__bd" style="height: 100%;">
                <div class="weui-tab">
                    <div class="weui-navbar">
                        <div class="weui-navbar__item weui-bar__item_on" data-id="exchange">
                            积分兑换
                        </div>
                        
                        <div class="weui-navbar__item" data-id="recharge">
                            积分充值
                        </div>
                    </div>

                    
                    <div class="weui-tab__panel" style="display: block" id="exchange">

                        <?php $__empty_1 = true; $__currentLoopData = $gifts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $gift): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                            <?php if(($gift['id_merchant_ticket'] && $gift['merchant_ticket']) || !$gift['id_merchant_ticket']): ?>
                                <div class="item">

                                    <img src="<?php echo e(asset('/images/version1/bgk_kfc.png')); ?>" width="60" height="60" alt="">

                                    <div class="item_right">

                                        <p class="title"><?php echo e(empty($gift['merchant_ticket'])?$gift['goods_name']:$gift['merchant_ticket']['name']); ?></p>
                                        

                                        <div style="line-height: 22px">
                                            <span class="need_credits"><?php echo e($gift['credits']); ?>积分</span>
                                            <button class="exchange" data-id="<?php echo e($gift['id_credits_exchange_rule']); ?>">兑换</button>
                                        </div>
                                    </div>
                                </div>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <div class="weui-loadmore weui-loadmore_line empty" style="display: none">
                                <span class="weui-loadmore__tips">暂无奖品可兑换:(</span>
                            </div>
                        <?php endif; ?>
                    </div>

                    
                    

                    
                    <div class="weui-tab__panel" id="recharge">
                        <div class="rechange_top">
                            <p class="recharge_title">积分充值</p>
                            <div class="input_div">
                                <input type="number" name="credits_num" value="">
                            </div>
                            <p class="credit_to_money">
                                兑换金额为 ￥<span class="to_money">0.00</span>
                            </p>
                        </div>

                        <div class="recharge_cash">
                            <button class="exchange_button" onclick="todoing('支付渠道确认中')">充值</button>

                            <div class="recharge_desc">
                                <p>积分充值说明：</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>

    <script type="text/javascript" class="navbar js_show">
        $(function(){
            $('.weui-navbar__item').on('click', function () {
                $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
                var id = $(this).data('id');
                $('.weui-tab__panel').hide();
                $('#'+id).show();
            });

            $('.exchange').click(function(){
                var id = $(this).data('id');
                $.ajax({
                    url:'/ajax/credits-exchange',
                    type:'post',
                    data:{'_token':window.laravel_csrf_token,'id':id},
                    success:function (res) {
                        if(res.code==4003){
                            showMsg(res.msg);
                            window.location.reload();
                            return;
                        }
                        showMsg(res.msg);
                    }
                });
            });
        });
    </script>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts._main', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>